<template>
    <div v-if="userStore.userInfo.Id">
        <h3>会员等级列表</h3>
        用户信息:{{userStore.userInfo.UserName}}
        <input type="button" value="增加等级" @click="add" />

        <table class="table table table-bordered">
            <tbody>
                <tr>
                    <td>ID</td>
                    <td>名称</td>
                    <td>权益</td>
                </tr>
                <tr v-for="item in data.list">
                    <td>{{item.Id}}</td>
                    <td>{{item.LevelName}}</td>
                    <td>{{item.LevelRights}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <div>您还没有登录</div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import axios from 'axios';
import {useUserStore}from '../stores/user';

const userStore=useUserStore();

const router = useRouter();

let data:any = reactive({
    list: [],
})

onMounted(() => {

    getList();
})
const add = () => {
    router.push("/memberleveladd")
}


const getList = () => {
    axios({
        method: 'get',
        url: '/api/Member/show'
    })
        .then((res) => {
            console.log(res);
            data.list = res.data;
        })
        .catch((err) => {
            console.log(err);
        });
}




</script>

<style scoped></style>